package com.htthorizon.model.controller;

import com.htthorizon.common.core.web.controller.BaseController;
import com.htthorizon.common.core.web.domain.AjaxResult;
import com.htthorizon.common.core.web.page.TableDataInfo;
import com.htthorizon.common.log.annotation.Log;
import com.htthorizon.common.log.enums.BusinessType;
import com.htthorizon.common.security.annotation.RequiresPermissions;
import com.htthorizon.model.domain.SceneTopic;
import com.htthorizon.model.request.SceneTopicAddReq;
import com.htthorizon.model.request.SceneTopicSearchReq;
import com.htthorizon.model.service.ISceneTopicService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Brilliant ,
 */
@RestController
@RequestMapping("/sceneTopic")
public class SceneTopicController extends BaseController {

    @Autowired
    private ISceneTopicService sceneTopicService;

    @GetMapping("/list")
    @ApiOperation("列表")
    @RequiresPermissions("system:config:menu")
    @Log(title = "场景专题分析", businessType = BusinessType.QUERY)
    public TableDataInfo page(SceneTopicSearchReq search){
        startPage();
        List<SceneTopic> list= sceneTopicService.list(search);
        return getDataTable(list);
    }

    @PostMapping("/save")
    @ApiOperation("保存")
    @RequiresPermissions("system:config:add")
    @Log(title = "场景专题分析", businessType = BusinessType.INSERT)
    public AjaxResult save(@RequestBody SceneTopicAddReq sceneTopicAddReq){
      boolean result=  sceneTopicService.save(sceneTopicAddReq);
      return AjaxResult.success();
    }

    @PostMapping("/edit")
    @ApiOperation("编辑")
    @RequiresPermissions("system:config:edit")
    @Log(title = "场景专题分析", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@RequestBody SceneTopicAddReq sceneTopicAddReq){
      boolean result=  sceneTopicService.edit(sceneTopicAddReq);
      return AjaxResult.success();
    }

    @GetMapping("/del/{id}")
    @ApiOperation("删除")
    @RequiresPermissions("system:config:delete")
    @Log(title = "场景专题分析", businessType = BusinessType.DELETE)
    public AjaxResult del(@PathVariable("id") Long id){
       boolean result= sceneTopicService.del(id);
       return AjaxResult.success();
    }

}
